package com.qianfeng.smartdevice.controller.advice;

import com.qianfeng.smartdevice.dto.R;
import com.qianfeng.smartdevice.execption.MyBaseException;
import com.qianfeng.smartdevice.execption.MyErrorCode;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * Created by wenka on 2022/3/20 15:56
 *
 * @author Jackiechan
 * @version 1.0
 * @since 1.0
 */
@RestControllerAdvice
public class MyErrorAdvice {
    @ExceptionHandler(MyBaseException.class)
    public R processMyBaseExc(MyBaseException e) {
        e.printStackTrace();
        return R.getR(e.getCode(), e.getMessage(), null);
    }

    @ExceptionHandler(Exception.class)
    public R processMyBaseException(Exception e) {
        e.printStackTrace();
        return R.getR(MyErrorCode.FAIL, "网络故障", null);
    }
}
